module.exports = class Subject{
  constructor(data, observersList){
    this.data = data;
    this.observersList = observersList;
    this.notifyAllObservers();
  }
  getData(){
    return this.data;
  }
  setData(data){
    this.data = data;
    this.notifyAllObservers();
  }
  attach(obvserver){
    this.observersList.push(obvserver);
  }
  notifyAllObservers(){
    this.observersList.forEach(item => {
      item.update(this.data);
    });
  }
}